<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 300px;
            height: 300px;
            background-color: red;
            position: relative;
        }

        p{
            width: 100px;
            height: 100px;
            background-color: blue;
            position: absolute;
        }
    </style>
</head>
<body>
    <div>
        <p></p>
    </div>
    <script>
        var div = document.getElementsByTagName('div')[0];
        var p = document.getElementsByTagName('p')[0];

        // div.onclick = function(){alert('鼠标左键单击')}
        // double 
        // div.ondblclick = function(){alert('鼠标左键双击')}
        // div.oncontextmenu = function(){alert('鼠标右键单击')}

        // div.onmouseup = function(){alert('鼠标抬起触发')}
        // div.onmousedown = function(){alert('鼠标按下触发 ')}

        // div.onmousemove = function(){console.log('鼠标移动触发')}
        div.onmouseover = function(){console.log('鼠标移入')}
        div.onmouseout = function(){console.log('鼠标移出')}

        // div.onmouseenter = function(){console.log('鼠标进入')}
        // div.onmouseleave = function(){console.log('鼠标离开')}


        // p是div的子元素
        // 进入div 会触发div的onmouseenter 
        // 从div进入p 不会触发div的onmouseenter
        // 从p进入div 也不会触发div的onmousleave
        // mouseover  mouseout 
        // 从div进入p 会触发div的onmouseover
        // 从p进入div 会触发div的onmouseout

    

    </script>
</body>
</html>